<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!-- Needs to build an exe with explicit Main as the MCJ functionality seems not to play well -->
    <!-- with the Roslyn-generated wrapper. -->
    <!-- Needed for CLRTestTargetUnsupported -->
    <RequiresProcessIsolation>true</RequiresProcessIsolation>
    <OutputType>Exe</OutputType>
    <ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>

    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <Optimize>true</Optimize>
    <!-- Generated shell script and corresponding assembly have different names -->
    <CLRTestTargetUnsupported Condition="'$(TargetOS)' == 'android'">true</CLRTestTargetUnsupported>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="BasicTestWithMcj.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="RunBasicTestWithMcj.cmd">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include="RunBasicTestWithMcj.sh">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <PropertyGroup>
    <CLRTestBatchPreCommands><![CDATA[
$(CLRTestBatchPreCommands)
mkdir r2r

REM Suppress some DOTNET and COMPlus variables for the duration of Crossgen2 execution
setlocal
set "DOTNET_GCName="
set "DOTNET_GCStress="
set "DOTNET_HeapVerify="
set "DOTNET_ReadyToRun="

"%CORE_ROOT%\corerun" %CORE_ROOT%\crossgen2\crossgen2.dll --out r2r\$(MSBuildProjectName).dll $(MSBuildProjectName).dll -r %CORE_ROOT%\*.dll

endlocal
set CLRCustomTestLauncher=RunBasicTestWithMcj.cmd --runCustomTest
]]></CLRTestBatchPreCommands>
    <CLRTestBashPreCommands><![CDATA[
$(CLRTestBashPreCommands)
mkdir r2r

# Suppress some DOTNET variables for the duration of Crossgen2 execution
export -n DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun

"$CORE_ROOT/corerun" $CORE_ROOT/crossgen2/crossgen2.dll --out r2r/$(MSBuildProjectName).dll $(MSBuildProjectName).dll -r $CORE_ROOT/*.dll

export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
chmod +x ./RunBasicTestWithMcj.sh
export CLRCustomTestLauncher="./RunBasicTestWithMcj.sh --runCustomTest"
]]></CLRTestBashPreCommands>
  </PropertyGroup>
</Project>
